package cn.edu.scau.cmi.chensixiao.javaFX;


import java.net.URL;
import java.util.ResourceBundle;

import cn.edu.scau.cmi.chensixiao.multipleton.Footballer;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class MultipletonController implements Initializable  {
	@FXML
	private Label nameLabel;
	@FXML
	private TextField nameText;
	@FXML
	private Button addButton;
	@FXML
	private Label listLabel;
	@FXML
	private TextArea nameList; 
	@FXML
	private Label showMessage;
	
	
	@Override
	public void initialize(URL location,ResourceBundle resources) {
	}
	
	@FXML
	
	private void buttonOnClick() {
		
		String name = nameText.getText();
	    boolean success = Footballer.addInstance(name);
	    if(!success) {
	    	showMessage.setVisible(true);
	    	
	    }
	    else
	    {
	    	String listString = nameList.getText();
			listString = listString + name + "\n";
			nameList.setText(listString);
	}


	
	
	
	}
}
